﻿using Autofac;

namespace IOCSample
{
    public class AutofacRunner : RunnerBase, IRunner
    {
        protected override string Name
        {
            get { return "Autofac"; }
        }

        public void Start(RunType runType)
        {
            var builder = new ContainerBuilder();

            if (runType == RunType.Singleton)
                builder.RegisterInstance(new AutofacRunner()).As<IRunner>().SingleInstance();
            else
                builder.RegisterInstance(new AutofacRunner()).As<IRunner>();

            var container = builder.Build();

            Time(() =>
            {
                var runner = container.Resolve<IRunner>();
            });

            container.Dispose();
        }
    }
}
